<?php

$latest_rev = $db->fetchOne("SELECT id FROM site_pages_revisions WHERE page_id=? ORDER BY id DESC LIMIT 1", $_REQUEST['id']);
$db->query("UPDATE site_pages_revisions SET published=NOW() WHERE id=?", $latest_rev);
$db->query("UPDATE site_pages SET revision_id=? WHERE site_id=? AND id=?", array($latest_rev, $site['id'], $_REQUEST['id']));
header('Content-type: application/json');
echo json_encode(array('ok' => true));